package com.project.controller;

import com.project.bean.UserBean;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

@RestController
@RequestMapping("user")
public class UserController {
    @RequestMapping("/land")
    public String login(String name , String password){
        if ("张三".equals(name)&&"123".equals(password)){
            return "登陆成功";
        }else {
            return "登陆失败";
        }
    }
    @RequestMapping(value = "/add",method = RequestMethod.POST)
    public String add(UserBean user){
        System.out.println(user);
        return "打印成功";
    }
    @RequestMapping("del/{userId}")
    public String del(@PathVariable("userId") int id){
        return "删除:"+id;
    }
    @RequestMapping("update")
    public String update(@RequestParam(value = "id",defaultValue = "0") int id,
                         HttpServletRequest request, HttpServletResponse response){

        String s = request.getParameter("name");
        System.out.println(s);
        return "修改："+id;
    }
}
